<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Account Controller
 * @package  CMS
 * @author Vui Nguyen - 09/04/2013 
 * @link http://joomlavui.info
 */
class Detail extends CI_Controller {
    
    protected $_arrParam;
    
    protected $_per_page = 12;
    
    function __construct() {
        parent::__construct();
        $this->load->library('session');
		$this->load->library('smarty3');
        $this->load->library('pagination');
		$this->smarty = new CI_Smarty3();
        // load models user,item
        $this->load->model('db_user_model');
        $this->db_user_model = new db_user_model();
        $this->load->model('db_item_model');
        $this->db_item_model = new db_item_model();
        $this->load->model('db_game_model');
        $this->db_game_model = new db_game_model();
        $this->load->model('db_logs_model');
        $this->db_logs_model = new db_logs_model();
        
        //require_once APPPATH . '../library/captcha/securimage.php';
        
        $this->_arrParam = $_REQUEST;
    }

    // ------------------------- HOME -------------------------------------
    function index() {
        $user = $this->session->userdata('user_info');
        
        if($user)
        {
            $this->smarty->assign("user_info",$user);
            //redirect('home');
        }
        
        //$itemid = $this->uri->rsegment(3);
        $transID = $this->uri->rsegment(3);
        //if(!is_numeric($itemid)){
            //show_404();
        //}
        //else{
            //$item = $this->db_item_model->getItem(array("id"=>$itemid));
            $itemLogs = $this->db_logs_model->getLogs(array("transID"=>$transID));
            $userKH = $this->db_user_model->getUser(array("username"=>$itemLogs[0]->username1));
            //print_r($userKH);exit;
            if(count($itemLogs)==0){
                show_404();
            }else{
                
            }
        //}
        $data['item'] = $itemLogs;
        $this->smarty->assign(array("infoKH"=>$userKH,"data"=>$data,"db_game_model"=>$this->db_game_model));
        
        $this->smarty->view("template/frontend/subs/01_detail","detail_1");
        
        if($itemLogs[0]->step==2){ //xác nhận giao dịch hợp lệ
            $this->smarty->view("template/frontend/subs/02_detail","detail_2");
        }
        if($itemLogs[0]->step==0){ //hủy giao dịch
            $this->smarty->view("template/frontend/subs/00_detail","detail_2");
        }
        
        
        $this->smarty->view('template/frontend/page/detail','content');
        $this->smarty->display('template/frontend/home');
    }
}

/* End of file account.php */
/* Location: ./application/controllers/account.php */